/****************************************************************************
 * Copyright (C) 2009-2013 Dimok
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 ****************************************************************************/
#ifndef HORIZONTALSCROLLBAR_HPP_
#define HORIZONTALSCROLLBAR_HPP_

#include "../GUI/gui.h"

class HorizontalScrollbar : public GuiElement, public sigslot::has_slots<>
{
	public:
		HorizontalScrollbar(int height);
		virtual ~HorizontalScrollbar();
		
		void SetDPadControl(bool a) { AllowDPad = a; }
		void ScrollOneLeft();
		void ScrollOneRight();
		int GetSelectedItem() { return SelItem; }
		int GetEntrieCount() { return EntrieCount; }
		void SetScrollSpeed(u16 speed) { ScrollSpeed = speed; }
		void SetBounds(iRect w);
		void Draw();
		void Update(GuiTrigger * t);
		
		void SetSelectedItem(int pos);
		void SetEntrieCount(int cnt);
		
		sigslot::signal1<int> listChanged;
		
	protected:
		void setScrollboxPosition(int SelItem);
		void CheckDPadControls(GuiTrigger *t);
		
		void OnLeftButtonHold(GuiButton *sender, int pointer, const POINT &p);
		void OnRightButtonHold(GuiButton *sender, int pointer, const POINT &p);
		void OnBoxButtonHold(GuiButton *sender, int pointer, const POINT &p);
		
		u32 ScrollState;
		u16 ScrollSpeed;
		bool AllowDPad;
		
		int MinWidth;
		int MaxWidth;
		int SelItem;
		int EntrieCount;
		bool listchanged;
		
		GuiButton * arrowLeftBtn;
		GuiButton * arrowRightBtn;
		GuiButton * scrollbarBoxBtn;
		
		GuiImage * scrollbarLeftImg;
		GuiImage * scrollbarRightImg;
		GuiImage * scrollbarTileImg;
		GuiImage * arrowLeftImg;
		GuiImage * arrowRightImg;
		GuiImage * scrollbarBoxImg;
		
		GuiImageData * scrollbarLeft;
		GuiImageData * scrollbarRight;
		GuiImageData * scrollbarTile;
		GuiImageData * arrowLeft;
		GuiImageData * arrowRight;
		GuiImageData * scrollbarBox;
		GuiImageData * oneButtonScrollImgData;
		
		GuiSound * btnSoundOver;
		GuiSound * btnSoundClick;
		
		GuiTrigger * trigHeldA;
};

#endif
